<?php

namespace app\index\service;

use app\index\dao\MemberDao;
use app\index\model\UM as UM;
use think\Collection;

/**
 * Class InviteMemberService
 * @package app\index\service
 */
class InviteMemberService
{
    // dao
    private MemberDao $memberDao;

    public function __construct(MemberDao $memberDao)
    {
        $this->memberDao = $memberDao;
    }

    /**
     * 列表
     * @param UM|null $user
     * @param int|null $page
     * @param int|null $page_size
     * @return Collection
     */
    public function index(?UM $user, ?int $page = null, ?int $page_size = null): Collection
    {
        $memberId = $user ? $user->id : null;

        if (!is_id($memberId)) {
            return \think\model\Collection::make();
        }

        //这里如果要修改查询，建议把查询放到dao层去
        return $this->memberDao->selectInviterMembers($memberId, 10);

    }
}
